home *** CD-ROM | disk | FTP | other *** search
/ Utilities Professional 1-1500 / Utilities Professional 1-1500 (1994)(WPD)[!].iso / 12511500 / var1432.dms / var1432.adf / NDUK-V40.lha / V40 / include / exec / macros.i < prev    next >
Text File  |  1993-10-15  |  3KB  |  155 lines

  1.     IFND    EXEC_MACROS_I
  2. EXEC_MACROS_I     SET     1
  3. **
  4. **    $VER: macros.i 39.0 (15.10.91)
  5. **    Includes Release 40.15
  6. **
  7. **    Handy macros for assembly language programmers.
  8. **
  9. **    (C) Copyright 1985-1993 Commodore-Amiga, Inc.
  10. **        All Rights Reserved
  11. **
  12.  
  13.         IFND    DEBUG_DETAIL
  14. DEBUG_DETAIL    SET    0    ;Detail level of debugging.  Zero for none.
  15.         ENDC
  16.  
  17.  
  18. JSRLIB        MACRO    ;FunctionName
  19.         XREF    _LVO\1
  20.         jsr    _LVO\1(a6)
  21.         ENDM
  22.  
  23. JMPLIB        MACRO    ;FunctionName
  24.         XREF    _LVO\1
  25.         jmp    _LVO\1(a6)
  26.         ENDM
  27.  
  28. BSRSELF    MACRO
  29.         XREF    \1
  30.         bsr    \1
  31.         ENDM
  32.  
  33. BRASELF    MACRO
  34.         XREF    \1
  35.         bra    \1
  36.         ENDM
  37.  
  38. BLINK        MACRO
  39.         IFNE    DEBUG_DETAIL
  40.           bchg.b #1,$bfe001  ;Toggle the power LED
  41.         ENDC
  42.         ENDM
  43.  
  44. TRIGGER        MACRO    ;<level> Trigger a hardware state analyzer
  45.         IFGE    DEBUG_DETAIL-\1
  46.           move.w #$5555,$2fe
  47.         ENDC
  48.         ENDM
  49.  
  50. CLEAR        MACRO
  51.         moveq.l #0,\1
  52.         ENDM
  53.  
  54. CLEARA        MACRO
  55.         suba.l    \1,\1    ;Quick way to put zero in an address register
  56.         ENDM
  57.  
  58. *************************************************************************
  59.         IFND    PRINTF
  60. PRINTF        MACRO    ; level,<string>,...
  61.         IFGE    DEBUG_DETAIL-\1
  62.         XREF    kprint_macro
  63. PUSHCOUNT    SET    0
  64.  
  65.         IFNC    '\9',''
  66.         move.l    \9,-(sp)
  67. PUSHCOUNT    SET    PUSHCOUNT+4
  68.         ENDC
  69.  
  70.         IFNC    '\8',''
  71.         move.l    \8,-(sp)
  72. PUSHCOUNT    SET    PUSHCOUNT+4
  73.         ENDC
  74.  
  75.         IFNC    '\7',''
  76.         move.l    \7,-(sp)
  77. PUSHCOUNT    SET    PUSHCOUNT+4
  78.         ENDC
  79.  
  80.         IFNC    '\6',''
  81.         move.l    \6,-(sp)
  82. PUSHCOUNT    SET    PUSHCOUNT+4
  83.         ENDC
  84.  
  85.         IFNC    '\5',''
  86.         move.l    \5,-(sp)
  87. PUSHCOUNT    SET    PUSHCOUNT+4
  88.         ENDC
  89.  
  90.         IFNC    '\4',''
  91.         move.l    \4,-(sp)
  92. PUSHCOUNT    SET    PUSHCOUNT+4
  93.         ENDC
  94.  
  95.         IFNC    '\3',''
  96.         move.l    \3,-(sp)
  97. PUSHCOUNT    SET    PUSHCOUNT+4
  98.         ENDC
  99.  
  100.         movem.l a0/a1,-(sp)
  101.         lea.l    PSS\@(pc),A0
  102.         lea.l    4*2(SP),A1
  103.         BSR    kprint_macro
  104.         movem.l (sp)+,a0/a1
  105.         bra.s    PSE\@
  106.  
  107. PSS\@        dc.b    \2
  108.         IFEQ    (\1&1)    ;If even, add CR/LF par...
  109.            dc.b 13,10
  110.         ENDC
  111.         dc.b    0
  112.         ds.w    0
  113. PSE\@
  114.         lea.l    PUSHCOUNT(sp),sp
  115.         ENDC    ;IFGE    DEBUG_DETAIL-\1
  116.         ENDM    ;PRINTF    MACRO
  117.         ENDC    ;IFND    PRINTF
  118.  
  119.  
  120. ;----------------------------------------------------------------------------
  121. ;Push a set of registers onto the stack - undo with POPM.  This prevents
  122. ;the need to update or synchronize two MOVEM instructions.  These macros
  123. ;assume an optimizing assembler that will convert single register  MOVEM
  124. ;to MOVE.  Because the REG assignment can't be reset, these macros do
  125. ;not nest.
  126. ;
  127. ;        PUSHM   d2/a2/a5
  128. ;        ...code...
  129. ;        POPM
  130. ;        RTS
  131. ;
  132. PUSHM_COUNT            SET    0
  133. PUSHM                MACRO
  134.                 IFGT    NARG-1
  135.                 FAIL    !!!! TOO MANY ARGUMENTS TO PUSHM !!!!
  136.                 ENDC
  137. PUSHM_COUNT            SET    PUSHM_COUNT+1
  138. PUSHM_\*VALOF(PUSHM_COUNT)      REG     \1
  139.                 movem.l PUSHM_\*VALOF(PUSHM_COUNT),-(sp)
  140.                 ENDM
  141.  
  142. ;
  143. ;Undo most recent PUSHM.  'POPM NOBUMP' allows multiple exit points.
  144. ;
  145. POPM                MACRO
  146.                 movem.l (sp)+,PUSHM_\*VALOF(PUSHM_COUNT)
  147.                 IFNC    '\1','NOBUMP'
  148. PUSHM_COUNT            SET    PUSHM_COUNT+1    ;error if re-used
  149.                 ENDC
  150.                 ENDM
  151. ;----------------------------------------------------------------------------
  152.  
  153.  
  154.     ENDC    ; EXEC_MACROS_I
  155.